﻿using Microsoft.Research.DynamicDataDisplay;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace dll_DynamicDataDisplay.ViewModels
{
    /// <summary>
    /// 图标元素类
    /// </summary>
    [Serializable]
    public class Vm_Element : INotifyPropertyChanged
    {
        #region NotifyProperty

        /// <summary>
        /// 图例名称
        /// </summary>
        public String Name
        {
            get { return _Name; }
            set
            {
                if (_Name != value)
                {
                    _Name = value;
                    this.OnPropertyChanged("Name");
                }
            }
        }
        private String _Name = "chart";

        /// <summary>
        /// 画刷
        /// </summary>
        public Brush Stroke_Brush
        {
            get 
            {
                BrushConverter brushConverter = new BrushConverter();
                return (Brush)brushConverter.ConvertFromString(this._Str_Stroke_Brush);
            }
            set
            {
                this._Str_Stroke_Brush = value.ToString();
                this.OnPropertyChanged("Stroke_Brush");
            }
        }
        private String _Str_Stroke_Brush = "#FF1176E5";

        /// <summary>
        /// 线宽
        /// </summary>
        public int Stroke_Thickness
        {
            get { return _Stroke_Thickness; }
            set
            {
                if (_Stroke_Thickness != value)
                {
                    _Stroke_Thickness = value;
                    this.OnPropertyChanged("Stroke_Thickness");
                }
            }
        }
        private int _Stroke_Thickness = 1;

        #endregion

        #region Methods


        /// <summary>
        /// 连接到ChartPlotter对象
        /// </summary>
        /// <param name="Plotter"></param>
        public virtual void ChartPlotter_Attach(ChartPlotter Plotter)
        {
            this.Plotter = Plotter;
        }

        /// <summary>
        /// 断开与ChartPlotter的连接
        /// </summary>
        public virtual void ChartPlotter_Detach()
        {
            this.Plotter = null;
        }

        /// <summary>
        /// 刷新图表数据
        /// </summary>
        public virtual void ReDraw()
        {

        }
        #endregion

        #region Private

        /// <summary>
        /// ChartPlotter对象
        /// </summary>
        [field: NonSerialized]
        protected ChartPlotter Plotter;

        #endregion

        #region NotifyPropertyChanged

        /// <summary>
        /// 属性变化委托
        /// </summary>
        [field: NonSerialized]
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// 属性变化响应
        /// </summary>
        /// <param name="propertyName"></param>
        public virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}
